﻿using System;

namespace program11
{
    class Program
    {
        static void Main(string[] args)
        {

            //使用递归实现 求1—n的积
            Console.WriteLine("1...5的积为" + GetSum(5));
            //使用非递归实现 求1—n的积
            Console.WriteLine("1...5的积为" + Multiplication(5));
            Console.WriteLine();
            string[] values = { "a", "b", "c" };
            for (int i = 0; i < values.Length; i++)
            {
                for (int j = 0; j < values.Length; j++)
                {
                    for (int k = 0; k < values.Length; k++)
                    {
                        Console.WriteLine(values[i] + values[j] + values[k]);
                    }

                }
            }
        }
        public static int GetSum(int n)
        {
            if (n == 1)
            {
                return 1;
            }
            //递归调用自己
            int tmp = GetSum(n - 1);
            return tmp * n;
        }
        public static int Multiplication(int n)
        {
            int product = 1;
            for (int i = 1; i <= n; i++)
            {
                product *= i;
            }
            return product;
        }
    }
}
